package com.yyn.Learning.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yyn.Learning.dto.front.CourseDetailDto;
import com.yyn.Learning.entity.EduCourse;
import com.yyn.Learning.entity.EduTeacher;
import com.yyn.Learning.service.EduChapterService;
import com.yyn.Learning.service.EduCourseService;
import com.yyn.Learning.service.EduTeacherService;
import com.yyn.Learning.service.EduVideoService;
import com.yyn.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/edusevice/indexfront")

public class IndexFrontController {
    @Autowired
    private EduCourseService eduCourseService;
    @Autowired
    private EduTeacherService eduTeacherService;
    @Autowired
    private EduChapterService eduChapterService;
//    查询前八条热门课程
//    查询前四条热门老师
    @ApiOperation("获取热门课程和老师")
    @GetMapping("getrecommend")
    public R getRecommend(){
        List<EduCourse> recommendCourse = eduCourseService.getRecommendCourse();
        List<EduTeacher> recommendTeacher = eduTeacherService.getRecommendTeacher();
        return R.success().data("recommendCourse",recommendCourse).data("recommendTeacher",recommendTeacher);
    }

//    课程详情
    @ApiOperation("课程详情")
    @GetMapping("CourseDetail/{courseId}/{token}")
    public R getCourseDetail(@PathVariable String courseId,@PathVariable String token){
//        1、dto
        CourseDetailDto courseDetail = eduCourseService.getCourseDetail(courseId,token);
//        2、视频小节
        List chapterTree = eduChapterService.getChapterTree(courseId);
        return R.success().data("courseDetailInfo",courseDetail).data("video",chapterTree);
    }
}
